<script src="/assets/dist/js/app.js"></script>
<script src="__STATIC__/js/wind.js"></script>
<script src="__STATIC__/js/frontend.js"></script>
<script src="/assets/dist/js/photo/jquery.min.js"></script>
<script src="/assets/dist/js/photo/popper.js"></script>
<script src="/assets/dist/js/photo/video.js"></script>
<script src="/assets/dist/js/photo/bootstrap.min.js"></script>
<script src="/assets/dist/js/photo/flatpickr.js"></script>
<script src="/assets/dist/js/photo/jquery.mCustomScrollbar.js"></script>
<script src="__TMPL__/public/assets/js/lazyload.js"></script>



<script>
	$(function () {
		$("#main-menu li.dropdown").hover(function () {
			$(this).addClass("open");
		}, function () {
			$(this).removeClass("open");
		});

		$("#main-menu a").each(function () {
			if ($(this)[0].href == String(window.location)) {
				$(this).addClass("text-blue");
			}
		});

		$.post("{:url('user/index/isLogin')}", {}, function (data) {
			if (data.code == 1) {
				if (data.data.user.avatar) {}

				$("#main-menu-user span.user-nickname").text(data.data.user.user_nickname ? data.data.user
					.user_nickname : data.data.user.user_login);
				$("#main-menu-user li.login").show();
				$("#main-menu-user li.offline").hide();

			}

			if (data.code == 0) {
				$("#main-menu-user li.login").hide();
				$("#main-menu-user li.offline").show();
			}

		});

		;
		(function ($) {
			$.fn.totop = function (opt) {
				var scrolling = false;
				return this.each(function () {
					var $this = $(this);
					$(window).scroll(function () {
						if (!scrolling) {
							var sd = $(window).scrollTop();
							if (sd > 100) {
								$this.fadeIn();
							} else {
								$this.fadeOut();
							}
						}
					});

					$this.find('#top-stick').click(function () {
						scrolling = true;
						$('html, body').animate({
							scrollTop: 0
						}, 500, function () {
							scrolling = false;
							$this.fadeOut();
						});
					});
				});
			};
		})(jQuery);

		$("#backtotop").totop();


	});
	$(window).scroll(function () {
		if ($(window).scrollTop() >= 100) {
			$(".top_bar").addClass('scroll').addClass('animated').addClass('slideInDown').addClass('shadow');
		} else {
			$(".top_bar").removeClass('scroll').removeClass('animated').removeClass('slideInDown').removeClass(
				'shadow');
		}
	});
	let bool = true;
	$('.user-ac-img').on('click', function (e) {
		if (bool) {
			$('.account-menu').css({
				"display": "block",
				"margin-top": "55px"
			});
			bool = false;
		} else {
			$('.account-menu').css({
				"display": "none",
				"margin-top": "54px"
			});
			bool = true;
		}

	})

	lazyload();

	// 分享图片
	$('#share').click(function () {
		var url = window.location.href;
		$.ajax({
			url: "{:url('user/ShareCode/share')}",
			type: 'post',
			data: {
				url: url,
			},
			dataType: 'json',
			success: function (data) {
				if (data.code == '1') {
					window.open(data.data, '_blank');
					console.log(data);
				} else if (data.code == '0') {

					if (data.url) {
						//返回带跳转地址
						window.location.href = data.url;
					} else {
						//刷新当前页
						reloadPage(window);
					}
				}
			}

		});
	})
</script>